package com.totoro.mysql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectionUtil {
    private static final String URL = "jdbc:mysql://127.0.0.1:3306/test" ;
    private static final int PORT = 3306 ;
    private static final String username = "root" ;
    private static final String password = "root123456" ;
    private static final String driverName = "com.mysql.jdbc.Driver" ;

    public static Connection getConnection(){
        Connection connection = null ;

        try {
            Class.forName(driverName) ;

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        try {
            connection = DriverManager.getConnection(URL, username, password) ;
            connection.setAutoCommit(false);
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return connection ;
    }

    public static void main(String[] args) {
        getConnection() ;
    }
}
